package com.yanxx.codegenerator.config;

import org.springframework.boot.context.properties.ConfigurationProperties;

/**
 * 编码生成器配置属性类
 */
@ConfigurationProperties(prefix = "code.generator")
public class CodeGeneratorProperties {

    /**
     * 编码前缀
     */
    private String prefix = "CODE";
    
    /**
     * 编码长度
     */
    private int length = 6;
    
    /**
     * 起始值
     */
    private long startValue = 1;
    
    /**
     * 存储类型: memory, file, redis, database
     */
    private String storageType = "memory";
    
    /**
     * 文件存储配置
     */
    private FileStorage fileStorage = new FileStorage();
    
    /**
     * Redis存储配置
     */
    private RedisStorage redisStorage = new RedisStorage();
    
    /**
     * 数据库存储配置
     */
    private DatabaseStorage databaseStorage = new DatabaseStorage();
    
    public static class FileStorage {
        /**
         * 文件路径
         */
        private String path = "./code_generator.json";

        public String getPath() {
            return path;
        }

        public void setPath(String path) {
            this.path = path;
        }
    }
    
    public static class RedisStorage {
        /**
         * Redis键前缀
         */
        private String keyPrefix = "code_generator";

        public String getKeyPrefix() {
            return keyPrefix;
        }

        public void setKeyPrefix(String keyPrefix) {
            this.keyPrefix = keyPrefix;
        }
    }
    
    public static class DatabaseStorage {
        /**
         * 生成器ID
         */
        private String generatorId = "default";

        public String getGeneratorId() {
            return generatorId;
        }

        public void setGeneratorId(String generatorId) {
            this.generatorId = generatorId;
        }
    }

    public String getPrefix() {
        return prefix;
    }

    public void setPrefix(String prefix) {
        this.prefix = prefix;
    }

    public int getLength() {
        return length;
    }

    public void setLength(int length) {
        this.length = length;
    }

    public long getStartValue() {
        return startValue;
    }

    public void setStartValue(long startValue) {
        this.startValue = startValue;
    }

    public String getStorageType() {
        return storageType;
    }

    public void setStorageType(String storageType) {
        this.storageType = storageType;
    }

    public FileStorage getFileStorage() {
        return fileStorage;
    }

    public void setFileStorage(FileStorage fileStorage) {
        this.fileStorage = fileStorage;
    }

    public RedisStorage getRedisStorage() {
        return redisStorage;
    }

    public void setRedisStorage(RedisStorage redisStorage) {
        this.redisStorage = redisStorage;
    }

    public DatabaseStorage getDatabaseStorage() {
        return databaseStorage;
    }

    public void setDatabaseStorage(DatabaseStorage databaseStorage) {
        this.databaseStorage = databaseStorage;
    }
}